<?php
function postData($url, $data = array(), $data1 = array()){      
	$header = array(
		'Content-Type: multipart/form-data',
	);
	$ch = curl_init(); 
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt( $ch, CURLOPT_HTTPHEADER, $header);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
	curl_setopt ($ch, CURLOPT_BINARYTRANSFER,true); 
	//curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
	curl_custom_postfields($ch, $data, $data1);
	$dxycontent = curl_exec($ch);
	curl_close($ch);
	return $dxycontent;
}

function curl_custom_postfields($ch, array $assoc = array(), array $files = array()) {	
	// invalid characters for name and filename
	static $disallow = array(, , ,);
	
	// build normal parameters
	foreach ($assoc as $k => $v) {
		$k = str_replace($disallow, _, $k);
		$body[] = implode(
, array(
			Content-Disposition: form-data; name={$k},
			,
			filter_var($v), 
		));
	}
	
	// build file parameters
	foreach ($files as $k => $v) {
		switch (true) {
			case false === $v = realpath(filter_var($v)):
			case !is_file($v):
			case !is_readable($v):
				continue; // or return false, throw new InvalidArgumentException
		}
		$data = file_get_contents($v);
		$v = call_user_func(end, explode(DIRECTORY_SEPARATOR, $v));
		$k = str_replace($disallow, _, $k);
		$v = str_replace($disallow, _, $v);
		$body[] = implode(
, array(
			Content-Disposition: form-data; name={$k}; filename={$v},
			Content-Type: application/octet-stream,
			,
			$data, 
		));
	}
	
	// generate safe boundary 
	do {
		$boundary = --------------------- . md5(mt_rand() . microtime());
	} while (preg_grep(/{$boundary}/, $body));
	
	// add boundary for each parameters
	array_walk($body, function (&$part) use ($boundary) {
		$part = --{$boundary}
{$part};
	});
	
	// add final boundary
	$body[] = --{$boundary}--;
	$body[] = ;
	
	// set options
	return @curl_setopt_array($ch, array(
		CURLOPT_POST       => true,
		CURLOPT_POSTFIELDS => implode(
, $body),
		CURLOPT_HTTPHEADER => array(
			Expect: 100-continue,
			Content-Type: multipart/form-data; boundary={$boundary}, // change Content-Type
		),
	));
}


?>